-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add geosearch autocomplete. #192
Conversation
@@ -59,7 +64,7 @@ export default class ReactTestingLibraryPal { | |||
const input = this.rr.getByLabelText(matcher, { | |||
selector: 'input, select' | |||
}) as HTMLInputElement; | |||
input.value = value; | |||
rt.fireEvent.change(input, { target: { value } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is important because it causes the onChange
handlers of the input fields to be called, if they are set, which is particularly important for the autocomplete widget. I actually had to get assistance from the Downshift community to figure this out and they were very quick to help out.
@@ -230,6 +230,11 @@ | |||
MIDDLEWARE.append( | |||
'rollbar.contrib.django.middleware.RollbarNotifierMiddlewareExcluding404') | |||
|
|||
CSP_CONNECT_SRC = [ | |||
"'self'", | |||
"https://geosearch.planninglabs.nyc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this could get out-of-sync with the actual web service we use to perform the geo search but um, at least the progressive enhancement error boundary will kick in and it will downgrade to baseline. Also, it is extremely unlikely to happen.
This progressively enhances onboarding step 1 to use the NYC Planning Labs autocomplete API, powered by the excellent Downshift React component.
If any network or runtime errors occur in the component, the app will fall back to the baseline experience (the separate address and borough fields) using a new
<ProgressiveEnhancement>
component that this PR introduces.To do
The user shouldn't actually be able to submit the form until they've selected a valid address that has the street and borough information.We can punt on this, now that the field shows server errors and only displays a non-empty value if it's a valid one.If the server says that either the address or borough field has errors, which would be very unusual, we should probably downgrade to the baseline experience just to be safe.We deal with the "this field is required" case now, which is going to be the vast majority of use cases, so I'm not going to worry about the extremely unlikely edge case where the server thinks the address is invalid.